import request from './request_wy';

// 获取实时热搜列表
export const reqGetHotKeywordList = () => request.get('/xhr/search/init.json');

// 获取实时关键字列表
export const reqGetSearchKeywordList = keyword => {
  // return request({
  //   url: '/xhr/search/searchAutoComplete.json',
  //   headers: {
  //     'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
  //   },
  //   params: {
  //     keywordPrefix: keyword,
  //   },
  // });

  return request.post(
    '/xhr/search/searchAutoComplete.json',
    {
      ['content-type']: 'application/x-www-form-urlencoded; charset=UTF-8',
    },
    {
      params: {
        keywordPrefix: keyword,
      },
    }
  );
};

// 搜索获取商品列表信息
export const reqGetSearchShopInfo = (
  keyword,
  descSorted,
  _stat_search,
  categoryId,
  floorPrice,
  upperPrice
) => {
  return request({
    url: '/xhr/search/search.json',
    params: {
      keyword,
      // __timestamp: 1642389194283, // id
      size: 40,

      _stat_search, // 'hot','history','autoComplete'(点击cell),'userhand'(这个是enter时)
      categoryId, // 点击分类时的id

      descSorted, // descSorted: false, // 降序排序
      floorPrice, // 最低价
      upperPrice, // 最高价

      stillSearch: false, // 静止搜索
      needPopWindow: true,
      // searchWordSource: 8, // 搜索词源
    },
    headers: {
      'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
  });
};
